//
//  CoBuyLotteryOperation.m
//  PlayBall
//
//  Created by yanfa on 16/3/31.
//
//

#import "CoBuyLotteryOperation.h"
#import "SBJsonWriter.h"
#import "JddUserProfile.h"

@implementation CoBuyLotteryOperation
@synthesize lotteryTypeId;
@synthesize issueId;
@synthesize multiple;
@synthesize moneyAmount;
@synthesize lotteryNumber;
//@dynamic description;
@synthesize BonusScale;
@synthesize guarantee;
@synthesize description;
@synthesize offer;

- (void)main{
    
    @autoreleasepool {
        JddNetDataCommunication *netDataCommunication = [[JddNetDataCommunication alloc] init];
        NSMutableDictionary *dictionaryBindCard = [NSMutableDictionary dictionaryWithCapacity:11];
        [dictionaryBindCard setObject:@"2" forKey:@"SchemeType"];
        [dictionaryBindCard setObject:@"1" forKey:@"BetType"];
        [dictionaryBindCard setObject:offer forKey:@"BuyShare"];
        [dictionaryBindCard setObject:BonusScale forKey:@"BonusScale"];
        [dictionaryBindCard setObject:guarantee forKey:@"AssureShare"];
        [dictionaryBindCard setObject:description forKey:@"Description"];
        [dictionaryBindCard setObject:@"" forKey:@"OpenUserList"];
        [dictionaryBindCard setObject:_SecrecyLevel forKey:@"SecrecyLevel"];
        [dictionaryBindCard setObject:lotteryNumber forKey:@"Number"];
        [dictionaryBindCard setObject:lotteryTypeId forKey:@"LotteryID"];
        [dictionaryBindCard setObject:issueId forKey:@"IssueID"];
        [dictionaryBindCard setObject:multiple forKey:@"Multiple"];
        [dictionaryBindCard setObject:moneyAmount forKey:@"Money"];
        //添加一个接口,用于适配是否是ios请求的
        //deviceType = ios
        [dictionaryBindCard setObject:@"ios" forKey:@"deviceType"];
        SBJsonWriter *jsonWriter = [[SBJsonWriter alloc] init];
        NSString *parameterValue = [jsonWriter stringWithObject:dictionaryBindCard];
        NSString *bodyString = [JddParameterBuilder buildParameterWithParameterJson:parameterValue actionCode:@"207"]; //207
        
        NSData *dataLotteryIssue = [netDataCommunication requestDataByPostBodyDataGouCai:[bodyString dataUsingEncoding:NSUTF8StringEncoding]];
        
//        NSString *resultDataString = [[NSString alloc] initWithData:dataLotteryIssue encoding:NSUTF8StringEncoding];
        //NSLog(@"resultDataString=%@",resultDataString);
        /*
         NSDictionary *ReDic = [NSJSONSerialization JSONObjectWithData:dataLotteryIssue options:NSJSONReadingMutableContainers error:nil];
         if([[ReDic objectForKey:@"Code"] intValue] == 0)
         {
         NSString*checkUrlString = [NSString stringWithFormat:@"%@?ck=%@",BASE_SERVER_IOS_BUY_LOTTERY_URL,[ReDic objectForKey:@"Data"]];
         NSURL *checkUrl = [NSURL URLWithString:checkUrlString];
         [[UIApplication sharedApplication] openURL:checkUrl];
         }*/
        
        [((NSObject*)self.delegate) performSelectorOnMainThread:@selector(CoBuyLotteryOperationResult:) withObject:dataLotteryIssue waitUntilDone:NO];
        
    }
}

@end
